namespace Vanilla.UI

import Vanilla

// TOP LEVEL GADGET
class TopLevel (Frame):
	def constructor (p as Desktop):
		super(p)
	
	def constructor ():
		self(null)
	
// TOOL TIP
class ToolTip (TopLevel):
	def constructor (p as Desktop):
		super(p)
	
	def constructor ():
		self(null)
	
	def constructor (p as Desktop, t as string):
		self(p)
		Label(self, t)
	
	def constructor (t as string):
		self(null,t)
	
	override def Reparented (o as Box, n as Box):
		GrabMouse()
	
	override def MouseMotion (x as double, y as double):
		Close() unless Size.Contains(x,y)
	
	override def MouseDown (b as MouseButton, x as double, y as double):
		Close()
	
	def Close ():
		ReleaseMouse()
		Parent.Remove(self) unless Parent == null

// DESKTOP
class Desktop (Box):
	public Panel as Panel
	public Background as Gadget
	
	// CONSTRUCTOR
	def constructor (p as Box):
		super(p)
		DrawFrame = false
		Background = ImageGadget(self, File("Wallpapers/Default.png"))
		Panel = Panel(self)
	
	// INIT
	static def Init (x as int, y as int):
		sdl = SDL(x,y)
		UI.Tool.CurrentDesktop = Desktop(sdl)
	
	// ARRANGE
	override def Arrange ():
		print "Desktop.Arrange()"
		unless Background == null:
			Background.SendToBack()
			Background.Rect = Rect(Size)
		
		unless Panel == null:
			Panel.Rect = Rect(0,Size.Height-Panel.Size.Height,Size.Width,Size.Height)
